package com.project.xsf.controller;

import com.alibaba.fastjson.JSONObject;
import com.project.xsf.entity.TAssessQuestion;
import com.project.xsf.service.TMentalityResultService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;

@CrossOrigin
@RestController
@RequestMapping("/tMentalityResult")
public class TMentalityResultController {
    @Autowired
    private TMentalityResultService tMentalityResultService;
    @PostMapping("/queryUserIfWritreMentalityAnswer")
    public Boolean queryUserIfWritreMentalityAnswer(HttpSession session){
        //判断用户是否填写心理问卷
        return tMentalityResultService.queryByMemberId(session);
    }
    @PostMapping("/addTMentalityResult")
    public void addTBodyType(@RequestBody String answers, HttpSession session){
        TAssessQuestion[][] objects = JSONObject.parseObject(answers, TAssessQuestion[][].class);
        tMentalityResultService.addTMentalityResult(objects,session);
    }
}
